package com.kf.bigbluebook.exception;

import com.kf.bigbluebook.common.BaseResponse;
import com.kf.bigbluebook.common.ErrorCode;
import com.kf.bigbluebook.common.ResultUntils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobeExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public BaseResponse businessExceptionHandler(BusinessException e){
        return ResultUntils.err(e);
    }
    @ExceptionHandler(RuntimeException.class)
    public BaseResponse systemExceptionHandler(RuntimeException e){
        return ResultUntils.err(ErrorCode.SYSTEM_ERROR,e.getMessage());
    }
}
